package org.styx.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.styx.datasource.DSContextHolder;

@RestController
@RequiredArgsConstructor
public class TestController {
    @GetMapping("/test")
    public String test(){
        return "hello world";
    }

    private final JdbcTemplate jdbcTemplate;



    @GetMapping("/query")
    @Transactional
    public String queryTest1(){
        DSContextHolder.setDSType(1);
        jdbcTemplate.queryForList("select * from test1");
        return "ok";
    }
}
